package m.jclecai.com.adapter.holder;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;

import butterknife.BindView;
import m.jclecai.com.R;
import m.jclecai.com.bean.RecordsBean;

/**
 * Created by zed on 2018/4/8.
 */

public class BetChampionHolder extends ViewHolder {
    @BindView(R.id.ivTeamOne)
    ImageView ivTeamOne;
    @BindView(R.id.iv_del)
    public ImageView iv_del;
    @BindView(R.id.tvTeamOne)
    TextView tvTeamOne;
    @BindView(R.id.ivTeamTwo)
    ImageView ivTeamTwo;
    @BindView(R.id.tvTeamTwo)
    TextView tvTeamTwo;
    @BindView(R.id.tvOdd)
    TextView tvOdd;
    @BindView(R.id.tvIndex)
    TextView tvIndex;
    @BindView(R.id.llContainer)
    View llContainer;

    public BetChampionHolder(Context context, int resource) {
        super(context, resource);
    }

    public void init(int position, final RecordsBean bean) {
        String title = bean.getTitle();
        String[] st = title.split("—");
        String index = (position < 10 ? "0" : "") + position;
        tvIndex.setText(index);
        tvTeamOne.setText(st[0]);
        tvTeamTwo.setVisibility(GONE);
        ivTeamTwo.setVisibility(GONE);
        //表示冠亚军
        if (st.length > 1) {
            tvTeamOne.append("-");
            tvTeamTwo.setVisibility(VISIBLE);
            tvTeamTwo.setText(st[1]);
        }
        String[] ft = bean.getFilename().split(",");
        Glide.with(getContext()).load(ft[0]).placeholder(R.mipmap.ic_cup_logo).into(ivTeamOne);
        if (ft.length > 1 && st.length > 1) {
            ivTeamTwo.setVisibility(VISIBLE);
            Glide.with(getContext()).load(ft[1]).placeholder(R.mipmap.ic_cup_logo).into(ivTeamTwo);
        }
        tvOdd.setText(bean.getOdds());
    }

}
